package com.liusy.code;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;

/**
 * 提示
 * 
 * @author liusy 2013-05-07
 *
 */
public final class Alert {
	
	private Shell shell;
	
	private static Alert alert;
	
	
	public Alert(Shell shell)
	{
		this.shell = shell;
	}
	public static void InitAlert(Shell shell)
	{
		alert = new Alert(shell);
	}
	
	public static int MsgBox(String title, String message)
	{
		return alert.msgBox(title, message);
	}
	
	public static int Confirm(String title, String message)
	{
		return alert.confirm(title, message);
	}
	
	private int msgBox(String title, String message) {
		MessageBox dialog = new MessageBox(shell);
		dialog.setText(title);
		dialog.setMessage(message);
		return dialog.open();
	}

	private int confirm(String title, String message) {
		MessageBox dialog = new MessageBox(shell, SWT.YES | SWT.NO);
		dialog.setText(title);
		dialog.setMessage(message);
		return dialog.open();
	}
}
